package com.itheima.easy.controller.customer;

import com.itheima.easy.base.AjaxResult;
import com.itheima.easy.dto.UserLoginRequestDto;
import com.itheima.easy.service.MemberService;
import com.itheima.easy.vo.LoginVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * <p>
 * 用户管理
 */
@Slf4j
@Api(tags = "客户管理")
@RestController
@RequestMapping("/customer/user")
public class CustomerUserController {

    @Resource
    private MemberService memberService;

    /**
     * C端用户登录--微信登录
     *
     * @param userLoginRequestDto 用户登录信息
     * @return 登录结果
     */
    @PostMapping("/login")
    @ApiOperation("登录")
    public AjaxResult<LoginVO> login(@RequestBody UserLoginRequestDto userLoginRequestDto) throws IOException {
        LoginVO login = memberService.login(userLoginRequestDto);
        return AjaxResult.success(login);
    }

}
